#region Copyright (c) 2013-06, Olaf Kober <amarok.projects@gmail.com>
//================================================================================
//	Permission is hereby granted, free of charge, to any person obtaining a copy
//	of this software and associated documentation files (the "Software"), to deal
//	in the Software without restriction, including without limitation the rights
//	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//	copies of the Software, and to permit persons to whom the Software is
//	furnished to do so, subject to the following conditions:
//
//	The above copyright notice and this permission notice shall be included in
//	all copies or substantial portions of the Software.
//
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//	THE SOFTWARE.
//================================================================================
#endregion

using System;
using System.Windows;


namespace Amarok.Presentation
{
	/// <summary>
	/// This type represents a ZoneDescription, which is a specific ViewDescription for embeddable controls. A 
	/// ViewDescription is a description of the combination of view, view model and associated controller. This
	/// description is capable to instantiate and connect view and controller and to manage the lifetimes of 
	/// these instances.
	/// </summary>
	public abstract class ZoneDescription : ViewDescription
	{
		#region ++ Public Interface ++

		/// <summary>
		/// Gets a reference to the control instance. This property returns null, if Create() was not called before.
		/// </summary>
		public FrameworkElement Control
		{
			get
			{
				if (base.View == null)
					return null;
				else
					return base.View.Control;
			}
		}

		#endregion

		#region ~~ Internal Interface ~~

		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		/// 
		/// <param name="controlType">
		/// The type of control in this combination of view, view model and controller.</param>
		/// <param name="controllerType">
		/// The type of controller in this combination of view, view model and controller.</param>
		/// 
		/// <exception cref="ArgumentNullException">
		/// A null reference was passed to a method that did not accept it as a valid argument.</exception>
		/// <exception cref="ArgumentException">
		/// A value was passed to a method that did not accept it as a valid argument, because 
		/// the value representing a type must be a sub-class of specified base type.</exception>
		internal ZoneDescription(Type controlType, Type controllerType)
			: base(controlType, controllerType)
		{
			Verify.IsSubclassOf(controlType, typeof(FrameworkElement), "controlType");
			Verify.IsSubclassOf(controllerType, typeof(Controller), "controllerType");
		}

		#endregion

	}
}
